package org.example.huawei;

import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * @author: lynn
 * @Descript:
 * @date: 2021/2/24 23:34
 * @version: 1.0
 */
public class HW19 {
    public static void main(String[] arg){
        /*Scanner s=new Scanner(System.in);
        Stack<String> stack=new Stack<>();
        HashMap<String,Integer> map=new HashMap<>();
        while(s.hasNext()){
            String[] arr=s.nextLine().split("\\\\");
            String line=arr[arr.length-1];
            String l=line.split(" ")[0];
            String ll=line.split(" ")[1];
            l=l.length()>16?l.substring(l.length()-16):l;
            line=l+" "+ll;
            if(stack.contains(line)){
                map.put(line,map.get(line)+1);
            }else{
                stack.push(line);
                map.put(line,1);
            }
        }
        Stack<String> stack1=new Stack<>();
        int i=0;
        while(!stack.isEmpty()){
            if(i==8){
                break;
            }
            stack1.push(stack.peek()+" "+map.get(stack.pop()));
            i++;
        }
        while(!stack1.isEmpty()){
            System.out.println(stack1.pop());
        }*/

        Scanner sc=new Scanner(System.in);
        //exception 11
        LinkedHashMap<String,Object> map=new LinkedHashMap<>();
        //exception position
        Map<String,String> postion=new HashMap<>();
        Queue<String> queue=new LinkedBlockingQueue<>();
        while (sc.hasNext()){
            String input=sc.nextLine();
            //进行空格切割
            String[] inputs=input.split("\\\\");
            //excetion 187
            String error=inputs[inputs.length-1];
            String errorWord=error.split(" ")[0];
            String targetStr=errorWord.length()>16?errorWord.substring(0,16):errorWord;
            String errorPostion=error.split(" ")[1];

            if (map.get(targetStr)==null){
                queue.add(targetStr);
                map.put(targetStr,1);
                postion.put(targetStr,errorPostion);
                if (map.size()>8){
                    String move=queue.remove();
                    map.remove(move);
                    postion.remove(move);
                }
            }else {
                map.put(targetStr,Integer.valueOf(map.get(targetStr)+"")+1);
            }
        }

        while (queue.size()!=0){
            String target =queue.remove();
            System.out.println(target+ " "+postion.get(target)+" "+map.get(target));
        }
    }
}
